<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Basic VarnishStat usage</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="varnish.example.admin.html">Basic VarnishAdmin usage</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="varnish.example.log.html">Basic VarnishLog usage</a></div>
 <div class="up"><a href="varnish.examples.html">范例</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="varnish.example.stat" class="section">
  <h2 class="title">Basic VarnishStat usage</h2>
  <p class="para">
   The example illustrates getting varnish statistic snapshot from shared
   memory
  </p>
  <div class="example" id="example-4577">
   <p><strong>Example #1 Get statistic snapshot</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />$vs&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">VarnishStat</span><span style="color: #007700">;<br /><br />try&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$data&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$vs</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getSnapshot</span><span style="color: #007700">();<br />}&nbsp;catch&nbsp;(</span><span style="color: #0000BB">VarnishException&nbsp;$e</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #0000BB">$e</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getMessage</span><span style="color: #007700">();<br />&nbsp;&nbsp;&nbsp;&nbsp;exit(</span><span style="color: #0000BB">3</span><span style="color: #007700">);<br />}<br /><br />exit(</span><span style="color: #0000BB">0</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

  </div>
 </div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="varnish.example.admin.html">Basic VarnishAdmin usage</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="varnish.example.log.html">Basic VarnishLog usage</a></div>
 <div class="up"><a href="varnish.examples.html">范例</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
